// Thud - a dynamic object-oriented language
// Copyright (C) 2009,2010 David H. Hovemeyer <david.hovemeyer@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/*
 * Token2.h
 *
 *  Created on: Dec 11, 2009
 *      Author: dhovemey
 */

#ifndef TOKEN2_H_
#define TOKEN2_H_

#include <string>
#include "fe/Location.h"

/**
 * A source token.
 */
class Token2 {
private:
	int m_tokenType;
	std::wstring m_lexeme;
	Location m_loc;

	Token2 *m_prev, *m_next;

public:
	/**
	 * Constructor.
	 *
	 * @param tokenType  of the token (using token numbers assigned by the generated parser)
	 * @param lexeme     the lexeme of the token
	 * @param loc        source location
	 * @param prev       the previous token from the source text
	 */
	Token2(int tokenType, const std::wstring &lexeme, const Location &loc, Token2 *prev);

	/** Destructor. */
	~Token2();

	/** Get token type (using token numbers assigned by the generated parser). */
	int getTokenType() const;

	/** Get the lexeme. */
	const std::wstring &getLexeme() const;

	/** Get the source location. */
	const Location &getLocation() const;

	/** Get previous token in source text (null if none). */
	Token2 *getPrev() { return m_prev; }

	/** Get next token in source text (null if none). */
	Token2 *getNext() { return m_next; }
};

#endif /* TOKEN2_H_ */
